﻿@using PagedList;
@using PagedList.Mvc;
@model IPagedList<Project_2._2.Models.Feedback>
@{
    ViewBag.Title = "Default";
    Layout = "~/Views/Shared/_AdminLayoutPage.cshtml";
}

<script src="~/Script/Jquery_Table_Sort/jquery-latest.js"></script>
<script src="~/Script/Jquery_Table_Sort/jquery.tablesorter.js"></script>

<script type="text/javascript" lang="ja">

    document.getElementById("feed").setAttribute("class", "activee")
</script>

<script type="text/javascript">
    $(document).ready(function () {
        $("table").tablesorter({ sortList: [[0, 0]], headers: { 0: { sorter: false }, 6: { sorter: false } } });
    });

</script>

<style>
    .search {
        width: 100%;
        height: 40px;
        padding: 10px 0 5px 10px;
    }

    .test {
        background: url('../Images/AdminDesign/nav-item-current-bg.png') repeat-x;
    }
</style>



<div class="grid_12">
    <div class="block-border">
        <div class="block-header">
            Quản Lý Ý Kiến Khách Hàng
        </div>
        <div class="block-content" style="overflow:scroll">

            <div class="search">

                @using (Html.BeginForm("Default", "AdminFeedback", FormMethod.Post, new { id = "Form" }))
                {
                    List<SelectListItem> record = new List<SelectListItem>();
                    int macdinh = 5;
                    if (ViewBag.record != null)
                    {
                        macdinh = int.Parse(ViewBag.record);
                    }
                    else
                    {
                        macdinh = 5;
                    }
                    for (int i = 5; i <= 50; i+=5)
                    {
                        if (macdinh == i)
                        { record.Add(new SelectListItem { Text = i + " Dòng", Value = i.ToString(), Selected = true }); }
                        else
                        { record.Add(new SelectListItem { Text = i + " Dòng", Value = i.ToString() }); }
                    }

                    <span>Dòng Hiển Thị </span> @Html.DropDownList("Record", record, new { @class = "select", onchange = "SelectedIndexChanged()" })

                    <span style="padding:0 10px 0 235px"> Từ Khóa </span> @Html.TextBox("KeyWord", null, new { @class = "Textbox", @placeholder = "Nhập từ khóa ..." })
                    List<SelectListItem> SearchBy = new List<SelectListItem>();
                    SearchBy.Add(new SelectListItem { Text = " --  Tìm Theo  -- ", Value = "0" });
                    SearchBy.Add(new SelectListItem { Text = "Họ Tên", Value = "HoTen" });                    
                    SearchBy.Add(new SelectListItem { Text = "Email", Value = "Email" });
                    SearchBy.Add(new SelectListItem { Text = "Tiêu Đề", Value = "TieuDe" });
                    SearchBy.Add(new SelectListItem { Text = "Nội Dung", Value = "NoiDung" });
                    <span> Tìm Theo </span>@Html.DropDownList("SearchBy", SearchBy, new { @class = "select" });

                    <input type="submit" class="MyButton" value="Tìm Kiếm" />
                }

            </div>
            @if (Model != null)
            {
                using (Html.BeginForm("Multi_Delete", "AdminFeedback", FormMethod.Post))
                { 
                    <table class="tablesorter" cellpadding="0" cellspacing="0">
                        <thead>
                            <tr>
                                <th style="width:40px; color:#ffffff">Chọn</th>
                                <th style="width:80px">Họ Tên</th>
                                <th>Email</th>
                                <th style="width: 70px">Tiêu Đề</th>
                                <th>Nội Dung</th>
                                <th>Ngày Gửi</th>
                                <th></th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach (var feedback in Model)
                            {
                                <tr>
                                    <td style="text-align:center"><input type="checkbox" name="feedbackIdsToDelete" id="feedbackIdsToDelete" value="@feedback.FeedbackId"></td>
                                    <td>@feedback.HoTen</td>
                                    <td>@feedback.Email</td>
                                    <td>@feedback.TieuDe</td>
                                    <td style="text-align:left">@feedback.NoiDung</td>
                                    <td style="width:70px">@String.Format("{0:dd/MM/yyyy}", feedback.NgayGui)</td>
                                    <td style="width:70px">
                                        <a class="tableActionButton check" rel="tooltip-top" title="Đăng" href="../AdminFeedback/Accept/@feedback.FeedbackId" onclick="return AcceptConfirm()"></a>

                                        <a class="tableActionButton delete" rel="tooltip-top" title="Hủy" href="../AdminFeedback/Delete/@feedback.FeedbackId" onclick="return DeleteConfirm()"></a>
                                    </td>
                                </tr>
                            }
                        </tbody>

                    </table>
                
                    <div style ="margin:13px 0 0 10px; float:left"><input type="submit" value=" Xóa Dòng Đã Chọn " class="MyButton" onclick="return DeleteConfirm()" /></div>
                }
                
                <table cellpadding="0" cellspacing="0" style="border-top:none; margin:5px 0px 5px 0; float:right;   ">
                   <tr>
                   
                       <td style="width:65px; text-align:right; font-weight:bold;padding-top:2px "> 
                           <span style="border: 1px solid #808080; border-right: none; padding: 7px 15px; margin-top: 10px; border-radius: 4px 0 0 4px; background-color: #428bca; color:#ffffff"> Trang</span></td>
                       <td >
                       <td>@Html.PagedListPager(Model, page => Url.Action("Default", new { page, rd = ViewBag.record }), new PagedListRenderOptions() { LinkToFirstPageFormat = "<<", LinkToPreviousPageFormat = " < ", LinkToNextPageFormat = " > ", LinkToLastPageFormat = ">>" })</td>
                       <td style="width:10px"></td>
                   </tr>
                </table>
            }
            else
            {
                <span>&nbsp &nbsp Không có dữ liệu...!</span>
            }
        </div>
    </div>
</div>

<script>
    function DeleteConfirm() {
        if (confirm("Bạn có thật sự muốn xóa không?"))
            return true;
        else
            return false;
    }

    function AcceptConfirm() {
        if (confirm("Bạn có muốn đăng ý kiến khách hàng?"))
            return true;
        else
            return false;
    }

    function SelectedIndexChanged() {
        $('#Form').submit();
    }
    document.getElementById("acc").setAttribute("class", "activee")
</script>